#define  _CRT_SECURE_NO_WARNINGS 1

#include "Sort.h"

void TestBubble()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	BubbleSort(arr, nums);
	PrintArray(arr, nums);
}

void TestInsert()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	InsertSort(arr, nums);
	PrintArray(arr, nums);
}

void TestSelect()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	SelectSort(arr, nums);
	PrintArray(arr, nums);
}

void TestShell()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	ShellSort(arr, nums);
	PrintArray(arr, nums);
}

void TestQuike1()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	QuikeSort1(arr, 0, nums - 1);
	PrintArray(arr, nums);
}

void TestQuike2()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9,10,11 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	QuikeSort2(arr, 0, nums - 1);
	PrintArray(arr, nums);
}

void TestQuike3()
{
	int arr[] = { 8,9,6,52,51,44,23,6,9,8,77,110,25,33,62 };
	int nums = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, nums);
	QuikeSort3(arr, 0, nums - 1);
	PrintArray(arr, nums);
}

void TestOP()
{
	int n = 100000;
	int* arr1 = (int*)malloc(n * sizeof(int));
	int* arr2 = (int*)malloc(n * sizeof(int));
	int* arr3 = (int*)malloc(n * sizeof(int));
	int* arr4 = (int*)malloc(n * sizeof(int));
	int* arr5 = (int*)malloc(n * sizeof(int));
	int* arr6 = (int*)malloc(n * sizeof(int));
	int* arr7 = (int*)malloc(n * sizeof(int));

	for (int i = 0; i < n; i++)
	{
		arr1[i] = i + rand();
		arr2[i] = arr1[i];
		arr3[i] = arr1[i];
		arr4[i] = arr1[i];
		arr5[i] = arr1[i];
		arr6[i] = arr1[i];
		arr7[i] = arr1[i];
	}

	int begin = clock();
	InsertSort(arr1, n);
	int end = clock();
	printf("InsertSort: %d\n", end - begin);

	begin = clock();
	BubbleSort(arr2, n);
	end = clock();
	printf("BubbleSort: %d\n", end - begin);

	begin = clock();
	SelectSort(arr3, n);
	end = clock();
	printf("SelectSort: %d\n", end - begin);

	begin = clock();
	ShellSort(arr4, n);
	end = clock();
	printf("ShellSort: %d\n", end - begin);

	begin = clock();
	QuikeSort1(arr4, 0, n - 1);
	end = clock();
	printf("QuikeSort1: %d\n", end - begin);

	begin = clock();
	QuikeSort2(arr4, 0, n - 1);
	end = clock();
	printf("QuikeSort2: %d\n", end - begin);

	begin = clock();
	QuikeSort3(arr4, 0, n - 1);
	end = clock();
	printf("QuikeSort3: %d\n", end - begin);

}

int main()
{
	//TestBubble();
	//TestInsert();
	//TestSelect();
	//TestShell();
	//TestQuike1();
	TestQuike2();
	//TestQuike3();
	//TestOP();

	return 0;
}